package trism.trifield.model {
	import flash.events.Event;
	import trism.Settings;
	import trism.game.model.common.stat.cells.CellsItem;
	import trism.trifield.model.helper.SlotsHelper;

	import com.samoiloff.framework.AbstractComponent;
	import com.samoiloff.framework.AbstractView;
	import com.samoiloff.framework.model.AbstractModel;

	/**
	 * @author Samoiloff  http://samoiloff.com/
	 */
	public class TrifieldModel extends AbstractModel {
		
		private var _cellsItem : CellsItem;
		private var _slotsHelper : SlotsHelper;
		
		public function TrifieldModel(component : AbstractComponent, view : AbstractView) {
			super(component, view);
			
			_cellsItem = new CellsItem(Settings.FIELD_WIDTH, Settings.FIELD_HEIGHT);
			
			
			_slotsHelper = new SlotsHelper(this);
			
			if (_view.mainMc.stage) {
				init();
			} else {
				_view.mainMc.addEventListener(Event.ADDED_TO_STAGE, init);
			}
		}
		
		private function init(e:Event = null):void {
			_view.mainMc.removeEventListener(Event.ADDED_TO_STAGE, init);
			complete();	
		}
		

		public function get cellsItem() : CellsItem {
			return _cellsItem;
		}

		public function get slotsHelper() : SlotsHelper {
			return _slotsHelper;
		}
	}
}
